//
//  ByBallNoticeDetailVC.m
//  caipiao_ios
//
//  Created by mc on 2018/8/27.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByBallNoticeDetailVC.h"
#import "ByBallNoticeDetailCell.h"
@interface ByBallNoticeDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;
@end

@implementation ByBallNoticeDetailVC

- (NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray arrayWithCapacity:1];
    }
    return _dataArray;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addLeftBackBarButtonItem];
    
   
    if (self.netModel.ball_type.integerValue == 1) {
         self.title = @"竞彩足球";
    }else{
         self.title = @"竞彩蓝球";
    }
    [self initViews];
    
    [self loadData];
    
    // Do any additional setup after loading the view.
}

- (void)loadData{
    ByNetModel *netModel = [[ByNetModel alloc] init];
    [ByCoreToolAlert showLoadind:@"加载中"];
    netModel.type = self.netModel.ball_type.integerValue;
    [ByApiOther drawNoticeBallInfo:netModel success:^(ByNetBaseResult *result) {
        [ByCoreToolAlert hideHud];
        [self.dataArray removeAllObjects];
        for (NSDictionary *dic in result.data[@"data"]) {
            ByNetModel *netModel = [[ByNetModel alloc] initContentWithDic:dic];
            [self.dataArray addObject:netModel];
        }
        [self.tableView reloadData];
        SLog(@"竞彩足球详情 = %@", result.data);
    
    } failure:^(ByNetBaseResult *result) {
        [ByCoreToolAlert showFailureWithText:result.msg];
    }];
    
}


- (void)initViews{
    
    self.view.backgroundColor = BY_BACKGROUND_COLOR;
    self.tableView = [[UITableView alloc] init];
    self.tableView.backgroundColor = BY_BACKGROUND_COLOR;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(0);
        make.right.equalTo(self.view).offset(0);
        if (@available(ios 11.0,*)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(0);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(0);
        } else {
            make.top.equalTo(self.view).offset(0);
            make.bottom.equalTo(self.view).offset(0);
        }
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ByBallNoticeDetailCell *cell = [ByBallNoticeDetailCell cellWithTableView:tableView];
    ByNetModel *netModel = [self.dataArray objectAtIndex:indexPath.row];
    cell.netModel = netModel;
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 175;
}


   



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
